# bootsmooth
# userhandlers.py

import web
import logging
import datetime

from bootsmooth import *

from google.appengine.api import urlfetch, mail

# example RPC
class contact:
	def POST(self):
	
		i = web.input()
		
		try:
			contact = {
				"name": i.name,
				"email": i.email,
				"phone": i.phone,
				"message": i.message,
				"datetime": datetime.datetime.now().strftime('%Y/%m/%d %H:%M')
			}
		
			sender = "Your Name <yourappengine@email>"
			subject = "Some Subject"
		
			message = mail.EmailMessage(sender=sender,subject=subject)
			message.to = "Destination <yourdestination@email>"
			
			# fetch a email template
			message.html = str(render.template('/www/contact.html', contact))
			message.send()
			
			return utility.json_dump({'content': message.html})
			
		
		except Exception as e:
			logging.warning(e)
			return utility.json_error(str(e))